package com.mda.log;

/**
 * Created by Administrator on 13-12-8.
 */
public abstract class Logger {
    static LogFactory factory;

    public static void initFactory() {
        try {
            //判断项目中是否有log4j的lib，没有会抛出异常
            Class.forName("org.apache.log4j.Logger");
            factory = new Log4jFactory();
        } catch (Exception e) {
            // TODO 初始化jdk中的log
        }
    }

    public static Logger getLogger(Class<?> clazz) {
        return factory.getLogger(clazz);
    }

    public static Logger getLogger(String name) {
        return factory.getLogger(name);
    }

    public abstract void debug(String msg);

    public abstract void debug(String msg, Throwable e);

    public abstract void info(String msg);

    public abstract void info(String msg, Throwable e);

    public abstract void warn(String msg);

    public abstract void warn(String msg, Throwable e);

    public abstract void error(String msg);

    public abstract void error(String msg, Throwable e);

    public abstract boolean isDebugEnabled();

    public static enum Lev {
        DEBUG, INFO, WARN, ERROR
    }
}
